package com.zxl.prototype.type3;
/**
 * ��ֵ���͵ĳ�Ա��������ֵ�ĸ���,���������͵ĳ�Ա����Ҳ�������ö���ĸ���.
 * @author zxl
 * 2016��7��8��
 */
public class Test {

	public static void main(String[] args) {
		testDeepCopy();
	}

	private static void testDeepCopy() {
		
		Prototype pro = new Prototype();
		pro.setName("original object");
		NewPrototype newObj = new NewPrototype();
		newObj.setId("test1");
		newObj.setPrototype(pro);

		NewPrototype copyObj = (NewPrototype) newObj.clone();
		copyObj.setId("testCopy");
		copyObj.getPrototype().setName("changed object");

		System.out.println("original object id:" + newObj.getId());
		System.out.println("original object name:"
				+ newObj.getPrototype().getName());

		System.out.println("cloned object id:" + copyObj.getId());
		System.out.println("cloned object name:"
				+ copyObj.getPrototype().getName());

	}
}
